package com.windfone.service.impl;

import java.util.List;

import com.windfone.common.FileTool;
import com.windfone.dao.SoftwareDao;
import com.windfone.model.Software;
import com.windfone.model.SoftwareType;
import com.windfone.service.SoftwareService;

public class SoftwareServiceImpl implements SoftwareService {
	private SoftwareDao softwareDao;
	public void setSoftwareDao(SoftwareDao softwareDao) {
		this.softwareDao = softwareDao;
	}

	public List<Software> getSoftwareByTypeId(int softwareTypeId) {
		return softwareDao.getSoftwareByTypeId(softwareTypeId);
	}

	public List<Software> getSoftwareById(int softwareId) {
		return softwareDao.getSoftwareById(softwareId);
	}

	public List<SoftwareType> getAllSoftwareType() {
		return softwareDao.getAllSoftwareType();
	}

	public int updateSoftwareById(Software bean) {
		return softwareDao.updateSoftwareById(bean);
	}

	public int addSoftware(Software bean) {
		return softwareDao.addSoftware(bean);
	}

	public int deleSoftware(Software bean) {
		bean = softwareDao.getSoftwareById(bean.getId()).get(0);
		String suffix = bean.getBigImagepath();
		FileTool.dealPic(suffix );
		
		suffix = bean.getSmallImagepath();
		FileTool.dealPic(suffix );		
		
		suffix = bean.getFileName();
		FileTool.dealFile(suffix );		
		
		return softwareDao.deleSoftware(bean);
	}

	public int getAllRecorderNumber(String whereCondition) {
		return softwareDao.getAllRecorderNumber(whereCondition);
	}

	public List<Software> getAllSoftware(int beginRecord, String whereCondition) {
		return softwareDao.getAllSoftware(beginRecord,whereCondition);
	}

}
